<script>
init({
  title: 'Footer Style',
  desc: 'Use `footerStyle` option to set the footer style formatter function.',
  links: ['bootstrap-table.min.css'],
  scripts: ['bootstrap-table.min.js']
})
</script>

<template>
  <table
    id="table"
    data-toggle="table"
    data-height="460"
    data-show-footer="true"
    data-footer-style="footerStyle"
    data-url="json/data1.json"
  >
    <thead>
      <tr>
        <th
          data-field="id"
          data-footer-formatter="idFormatter"
        >
          ID
        </th>
        <th
          data-field="name"
          data-footer-formatter="nameFormatter"
        >
          Item Name
        </th>
        <th
          data-field="price"
          data-footer-formatter="priceFormatter"
        >
          Item Price
        </th>
      </tr>
    </thead>
  </table>
</template>

<script>
  window.idFormatter = () => 'Total'

  window.nameFormatter = data => data.length

  window.priceFormatter = data => {
    const field = this.field

    return `$${data.map(function (row) {
      return +row[field].substring(1)
    }).reduce(function (sum, i) {
      return sum + i
    }, 0)}`
  }

  window.footerStyle = column => ({
    id: {
      classes: 'uppercase'
    },
    name: {
      css: { 'font-weight': 'normal' }
    },
    price: {
      css: { color: 'red' }
    }
  }[column.field])
</script>

<style>
.uppercase {
  text-transform: uppercase;
}
</style>
